<form method="post" class="form-horizontal" novalidate>
    {% csrf_token %}
    {% for dic in form %}
        <div class="col-sm-12">
            <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">{{ dic.item.label }}</label>
                <div class="col-sm-10">
                    <!-- 判断，如果field是ModelChoiceField，则FK； 如果是ModelMultipleChoiceField，则M2M -->

                    <div class="related-widget-wrapper">
                        <div id="dic_item">
                            {{ dic.item }}
                        </div>
                        <div class="dic_is_popup">
                            {% if dic.is_popup %}
                                <a onclick="popUp('{{ dic.popup_url }}')"><span
                                        class="glyphicon glyphicon-pencil ">&nbsp;<span
                                        class="glyphicon glyphicon-plus"></span></span></a>
                            {% endif %}
                        </div>
                    </div>
                    <div style="color: red">
                        {{ dic.item.errors.0 }}
                    </div>
                </div>
            </div>
        </div>
    {% endfor %}
    <div class="col-sm-offset-10 col-sm-2">
        <input type="submit" class="btn btn-primary" style="width: 120px" value="提交">
    </div>
</form>
<script>
    function popupCallback(dic) {
        var op = document.createElement('option');
        op.value = dic.id;
        op.text = dic.text;
        op.setAttribute('selected', 'selected');
        document.getElementById(dic.popbackid).appendChild(op);

    }

    function popUp(url) {
        var popupPage = window.open(url, url, "status=1, height:200, width:350, toolbar=0, resizeable=0");
    }
</script>